<%@ page import="com.soft.entity.UserInfo" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>电子商城</title>
<link href="styles/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%
    int flag = (int)request.getSession().getAttribute("flag");
    if (flag == 33)
        out.print("<script>alert('冻结成功！')</script>");
    else if (flag == 34)
        out.print("<script>alert('解封成功！')</script>");
    else if (flag == 35)
        out.print("<script>alert('冻结失败！')</script>");
    else if (flag == 36)
        out.print("<script>alert('解封失败！')</script>");
    request.getSession().setAttribute("flag", 0);
%>
<div class="main">



<div class="top">
  <p>
      <a href="goodsManageList.jsp">公告管理</a> |
      <a href="<c:url value="/GoodsList"/>">商品管理</a> |
      <a href="<c:url value="/MemberManageList"/>">会员管理</a> |
      <a href="<c:url value="/OrderManageList"/>">订单管理</a> |
      <a href="manage1.jsp">退出后台</a>
  </p>
</div>
  <div class="adm_con">
    <div class="bg_3">
      <div class="bg_1">
        <div class="bg_2">
          <h3><img src="images/25.gif" class="flo_right" /><img src="images/23.gif" class="flo_left" /><span>会员管理</span></h3>
          <div class="padd">
              <span id="spanFirst">第一页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span> <span
                  id="spanLast">最后一页</span> 第<span id="spanPageNum"></span>页/共<span id="spanTotalPage"></span>页
							<p> [会员列表]</p>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td scope="col" width="10%"> 用户名 </td>
                <td scope="col" width="12.5%"> 真实姓名 </td>
                  <td scope="col" width="12.5%"> 用户等级 </td>
                <td scope="col" width="20%"> 城 市 </td>
                <td scope="col" width="15%"> 电 话 </td>
                <td scope="col" width="20%"> E-mail </td>
                <td scope="col" width="10%"> 冻结/解冻 </td>
              </tr>
            </table>
              <table width="100%" border="0" cellspacing="0" cellpadding="0" id="table">
                <c:forEach items="${UserList}" var="U">
                    <tr>
                        <form action="<c:url value="/MemberManageList?account=${U.id}"/>" method="post">
                            <td width="10%"> <a href="memberManageView.jsp?userId=${U.id}">${U.id}</a> </td>
                            <td width="12.5%">${U.name}</td>
                            <td width="12.5%">
                                <c:if test="${U.level eq 0}">普通会员</c:if>
                                <c:if test="${U.level eq 1}">黄金会员</c:if>
                                <c:if test="${U.level eq 2}">钻石会员</c:if>
                            </td>
                            <td width="20%">${U.address}</td>
                            <td width="15%">${U.telephone}</td>
                            <td width="20%">${U.email}</td>
                            <td width="10%">
                                <c:if test="${U.status eq 0}">
                                    <input type="image" alt="冻结" src="images/31.gif" style="border:0; cursor:hand;"/>
                                </c:if>
                                <c:if test="${U.status eq 1}">
                                    <input type="image" alt="正常" src="images/32.gif" style="border:0; cursor:hand;"/>
                                </c:if>

                            </td>
                        </form>
                    </tr>
                </c:forEach>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</body>
</html>
<script>
    var theTable = document.getElementById("table");
    var totalPage = document.getElementById("spanTotalPage");
    var pageNum = document.getElementById("spanPageNum");
    var spanPre = document.getElementById("spanPre");
    var spanNext = document.getElementById("spanNext");
    var spanFirst = document.getElementById("spanFirst");
    var spanLast = document.getElementById("spanLast");
    var numberRowsInTable = theTable.rows.length;
    var pageSize = 1;
    var page = 1;

    //下一页
    function next() {

        hideTable();

        currentRow = pageSize * page;
        maxRow = currentRow + pageSize;
        if (maxRow > numberRowsInTable) maxRow = numberRowsInTable;
        for (var i = currentRow; i < maxRow; i++) {
            theTable.rows[i].style.display = '';
        }
        page++;

        if (maxRow === numberRowsInTable) { nextText(); lastText(); }
        showPage();
        preLink();
        firstLink();
    }

    //上一页
    function pre() {

        hideTable();
        page--;

        currentRow = pageSize * page;
        maxRow = currentRow - pageSize;

        if (currentRow > numberRowsInTable) currentRow = numberRowsInTable;

        for (var i = maxRow; i < currentRow; i++) {
            theTable.rows[i].style.display = '';
        }

        if (maxRow === 0) {
            preText(); firstText();
        }
        showPage();
        nextLink();
        lastLink();
    }

    //第一页
    function first() {
        hideTable();
        page = 1;
        for (var i = 0; i < pageSize; i++) {
            theTable.rows[i].style.display = '';
        }
        showPage();
        preText();
        if (page === pageCount()) nextText();
        else nextLink();
        lastLink();
    }

    //最后一页
    function last() {
        hideTable();
        page = pageCount();
        currentRow = pageSize * (page - 1);
        for (var i = currentRow; i < numberRowsInTable; i++) {
            theTable.rows[i].style.display = '';
        }
        showPage();
        nextText();
        if (pageCount() === 1) preText();
        else preLink();
        firstLink();
    }

    function hideTable() {
        for (var i = 0; i < numberRowsInTable; i++) {
            theTable.rows[i].style.display = 'none';
        }
    }

    function showPage() {
        pageNum.innerHTML = page;
    }

    //总共页数
    function pageCount() {
        var count = 0;
        if (numberRowsInTable % pageSize !== 0) count = 1;
        return parseInt(numberRowsInTable / pageSize) + count;
    }

    //显示链接
    function preLink() { spanPre.innerHTML = "<a href='javascript:pre();'>上一页</a>"; }
    function preText() { spanPre.innerHTML = "上一页"; }

    function nextLink() { spanNext.innerHTML = "<a href='javascript:next();'>下一页</a>"; }
    function nextText() { spanNext.innerHTML = "下一页"; }

    function firstLink() { spanFirst.innerHTML = "<a href='javascript:first();'>第一页</a>"; }
    function firstText() { spanFirst.innerHTML = "第一页"; }

    function lastLink() { spanLast.innerHTML = "<a href='javascript:last();'>最后一页</a>"; }
    function lastText() { spanLast.innerHTML = "最后一页"; }

    //隐藏表格
    function hide() {
        for (var i = pageSize; i < numberRowsInTable; i++) {
            theTable.rows[i].style.display = 'none';
        }
        totalPage.innerHTML = pageCount();
        pageNum.innerHTML = '1';
        if (pageCount() !== 1) nextLink();
        firstLink();
        lastLink();
    }
    hide();
</script>
